# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=pam_wrapper
pkgver=1.1.5
pkgrel=1
pkgdesc="Tool to test PAM applications and PAM modules"
url="https://cwrap.org/pam_wrapper.html"
arch=(loong64 x86_64)
license=(GPL3)
depends=(
  pam
  python
)
makedepends=(
  cmake
  cmocka
  doxygen
  git
  graphviz
  ninja
)
provides=(
  libpam_wrapper.so
  libpamtest.so
)
_commit=b223df9f35e750811f812c8cfb85bc81c196102e  # tags/pam_wrapper-1.1.5^0
source=("git+https://git.samba.org/pam_wrapper.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^pam_wrapper-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  local cmake_options=(
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=None
    -D UNIT_TESTING=true
  )

  cmake -S $pkgname -B build -G Ninja "${cmake_options[@]}"
  cmake --build build
  cmake --build build --target doc
}

check() {
  cd build
  ctest --output-on-failure --stop-on-failure -j$(nproc)
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  mkdir -p "$pkgdir/usr/share/doc"
  cp -a build/doc/html "$pkgdir/usr/share/doc/$pkgname"
  cp -a build/doc/man/man3 "$pkgdir/usr/share/man"
}

# vim:set sw=2 sts=-1 et:
